﻿using System;
using System.Collections.Generic;
using IntoNails.Infrastructure.ViewModels;

namespace IntoNails.Infrastructure.Extensions
{
    public static class TreeNodeViewModelExtensions
    {
        public static IEnumerable<ITreeNodeViewModel> TakeUntil(this IEnumerable<ITreeNodeViewModel> source, Func<ITreeNodeViewModel, bool> predicate)
        {
            foreach (ITreeNodeViewModel item in source)
            {
                yield return item;
                if (predicate(item))
                {
                    yield break;
                }
            }
        }
    }
}
